Packaging a Java Application
Packaging a Java application to run under the Mac OS creates a file that contains the following items:
The packaged Java application does not contain the Java virtual machine. The host computer that executes the Java application must supply the virtual machine through the MRJ libraries.
- the Java classes that make up the application
- predefined settings or parameters for the Java application (class paths, arguments, and so on)
- any files the Java application requires (images, data, and so on)
- a wrapper Mac OS application to set up the Java virtual machine and call the application's
main
method- any Mac OS resources used by the wrapper application
To create a packaged Java application using JBindery, you should do the following:
During the save process, JBindery displays some progress information as it packages the files you specified in the Virtual File System panel. The saved file can now be launched like a Mac OS application. Alternatively, if you select the Run button while still in JBindery, JBindery automatically quits and launches your packaged application.
- Put all the files your Java application requires into a single folder hierarchy. This folder should not contain any Mac OS resource files.
- Drag the class file or zip package containing the application's
main
method onto the JBindery icon. Alternatively, you can launch JBindery and then enter the class name manually in the Command panel.- In the Command panel, enter any parameters your application requires and choose paths for console output and input.
- In the Properties panel, enter any property/value pairs you want to include with your application.
- In the Appearance panel, select any desired appearance features.
- In the Security panel, specify any proxy servers, if desired, and choose whether you want to use the code verifier.
- In the Application panel, choose a signature (also called a creator) for your application. If you plan to distribute your application (whether commercially or as shareware), you should register the creator with Apple. The default creator is
'????'
. See "The Application Panel" (page 13) for more information.- If desired, you can change the default application heap sizes in the Application panel.
- If you have any Mac OS resources you want to include, drag the compiled resource file onto the Merge Resources From box in the Application panel (or click on the box to select the resource file manually). See "Mac OS Resources" (page 20) for more information about resources.
- In the Virtual File System panel, drag the folder containing your Java application's class files onto the Copy Contents of Folder Hierarchy box (or click on the box to choose the folder manually).
- In the Classpath panel, select the Add Manually button. In the dialog box that appears, enter the name you chose for your virtual file system's root directory as a file URL. Unless you changed the default directory
$VFS
in the Virtual File System panel, your class path should befile:///$VFS
. Select the OK button when finished.- Delete any other class paths so that your virtual file system path is the only one that is searched.
- Choose Save Settings... from any of the panels. When the save dialog box appears, choose a name for your packaged Java application file.
- Select the Save as Application checkbox in the save dialog box and save your packaged file.
If desired, you can keep the Java application class files separate from the application file by not selecting the Copy Contents of Folder Hierarchy checkbox in the Virtual File System panel. The resulting application files then contains only the following items:
To build a packaged application with separate class files, you should do the following:
- predefined settings or parameters for the Java application (class paths, arguments, and so on)
- a wrapper Mac OS application to set up the Java virtual machine and call the application's main method
- any Mac OS resources used by the wrapper application
The resulting application file can be launched like a Mac OS application assuming that the required Java classes can be found.
- Follow steps 2 through 8 as for creating an application with packaged class files.
- In the Classpath panel, enter any additional paths you want searched when looking for the Java application's class files.
- Choose Save Settings... from any of the panels. When the save dialog box appears, choose a name for your application file.
- Select the Save as Application checkbox in the save dialog box and save your packaged file.